package org.action;

import java.util.*;


import org.bean.O2rankrank;
import org.service.CapableService;
import org.util.PageBean;

import com.opensymphony.xwork2.ActionSupport;

@SuppressWarnings("serial")
public class PlayerCapableAction extends ActionSupport {

	private CapableService capableservice;
	private PageBean pageBean;
	private O2rankrank oldrank;
	private int page;
	private int olds;
	private int news;
	private int up;


	public String execute() throws Exception {

		if(page==0){
			page=1;
		}
		
		this.pageBean = capableservice.queryForPageCapable(20, page);
		List<O2rankrank> list = pageBean.getList();
		
		
		for (int i = 0; i < list.size(); i++) {
			
			O2rankrank O2rankrank = list.get(i);
			//System.out.println(O2rankrank.getNickname());
		
			
			oldrank = capableservice.selectByuid(O2rankrank.getUid());
			
			if(oldrank!=null)
			{
			olds =oldrank.getRank();
			news =O2rankrank.getRank();
			up = olds-news;
			O2rankrank.setRankup(up);
			}
			
		}
		

		return SUCCESS;

	}

	public void setPage(int page) {
		this.page = page;
	}

	public CapableService getCapableservice() {
		return capableservice;
	}

	public void setCapableservice(CapableService capableservice) {
		this.capableservice = capableservice;
	}

	public PageBean getPageBean() {
		return pageBean;
	}

	public void setPageBean(PageBean pageBean) {
		this.pageBean = pageBean;
	}

	public int getPage() {
		return page;
	}

	public O2rankrank getOldrank() {
		return oldrank;
	}

	public void setOldrank(O2rankrank oldrank) {
		this.oldrank = oldrank;
	}


	
}
